//
//  KJTimeTransfer.m
//  Enote
//
//  Created by Jack on 2016/10/24.
//  Copyright © 2016年 Jack. All rights reserved.
//

#import "KJTimeTransfer.h"

@implementation KJTimeTransfer

+ (NSInteger)transferIntegerWithTimestr:(NSString *)timeStr{
    
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    dateFormatter.dateFormat = @"yyyy-MM-dd HH:mm:ss";
    NSDate *date = [dateFormatter dateFromString:timeStr];
    NSTimeInterval timeInterval = [date timeIntervalSince1970];
    NSInteger dateInt = (NSInteger)timeInterval;
    
    return dateInt;
}

+ (NSString *)transferTimestamp:(NSInteger)timestamp toFormat:(NSString *)format {
    NSTimeInterval timeInterval = timestamp;
    NSDate *date = [NSDate dateWithTimeIntervalSince1970:timeInterval];
    NSDateFormatter *dateFm = [[NSDateFormatter alloc] init];
    dateFm.dateFormat = format;
    NSString *dateStr = [dateFm stringFromDate:date];
    return dateStr;
}

@end
